
//获取指定的cookie
function getCookie(cookieName) {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for(var i = 0; i < arrCookie.length; i++){
        var arr = arrCookie[i].split("=");
        if(cookieName == arr[0]){
            return arr[1];
        }
    }
    return "";
}

//便捷创建html元素
buildHTML = function(tag, html, attrs) {
    // you can skip html param
    if (typeof (html) != 'string') {
        attrs = html;
        html = null;
    }
    var h = '<' + tag;
    for (attr in attrs) {
        if (attrs[attr] === false) continue;
        h += ' ' + attr + '="' + attrs[attr] + '"';
    }
    return h += html ? ">" + html + "</" + tag + ">" : "/>";
};

//刷新用户登陆状态
function refreshLoginState(){
    statuses.loginedUserid=getCookie("loginedUserid");
    statuses.loginedUsername=getCookie("loginedUsername");
}

//弹出信息框
function popMessage(txt) {
    $("#popmessage").remove()
    var txtele = $("<div id=\'popmessage\' >"+txt+"</div>")
    $('body').append(txtele)
    setTimeout(function () {
        $("#popmessage").fadeOut();
    },1000);
}